package com.foxzzz;

import com.foxzzz.command.CmdHandler;
import com.foxzzz.operation.InitDataBaseOperation;
import com.foxzzz.util.MyListenner;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class ItemStorePlugin extends JavaPlugin{

    @Override
    public void onEnable() {
        super.onEnable();
        getServer().getPluginManager().registerEvents(new MyListenner(this),this);
        new InitDataBaseOperation().init();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            Player player= (Player) sender;
            String[] arg1=new String[args.length-1];
            for (int i = 1; i < args.length; i++) {
                arg1[i-1]=args[i];
            }
            CmdHandler.exec(player,args[0],arg1);
        } else {
            sender.sendMessage("You must be a player!");
            return false;
        }
        return false;
    }
}
